package com.paomi.client.fragment.information.presenter;

import android.os.Handler;

import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
import com.hannesdorfmann.mosby3.mvp.MvpView;
import com.paomi.client.fragment.first.model.NewsJson;
import com.paomi.client.fragment.information.InformationMvpView;
import com.paomi.client.net.Api;
import com.paomi.client.net.BaseCallback;
import com.paomi.client.net.Constants;

import org.greenrobot.eventbus.EventBus;

import java.util.HashMap;
import java.util.Map;

import retrofit2.Call;

/**
 * Created by pc on 2018/10/25
 * Describe:
 * com.paomi.client.fragment.first.presenter
 */
public class InformaticaFraPre extends MvpBasePresenter<InformationMvpView> {

    public void setInfoData(int pageNme, String content, String classify) {
        Map<String, String> stringMap = new HashMap<>();
        stringMap.put("content", content);
        stringMap.put("pageNum", "" + pageNme);
        stringMap.put("pageSize", "" + Constants.PAGE_SIZE);
        stringMap.put("sort", classify);//0是时间，1是热度
        Api.getInstanceService(Constants.Ticket_URL).getSearchNews(stringMap).enqueue(new BaseCallback<NewsJson>() {
            @Override
            public void onResponse(Call<NewsJson> call, NewsJson result) {
                if(result.getReturnData()!=null){
                    if(isViewAttached()){
                        getView().getInfoData(result.getReturnData().getData());
                    }
                }
            }
        });
    }
}
